package com.remote.server;

import com.remote.common.RemoteConfiguration;
import io.netty.channel.ChannelOption;
import lombok.Data;

@Data
public class RemoteServerConfiguration extends RemoteConfiguration {
    private String host = "0.0.0.0";
    private int port = 9000;
    private Boolean tcpNodelay = true;
    // 连接超时时间，默认20分钟
    private Integer connectionTimeoutMills = 1000 * 10;
    private String allocator;
    private String recvAllocator;
    private String messageSizeEstimator;
    private Integer writeSpinCount;
    private String writeBufferWaterMark;
    private Boolean allowHalfClosure;
    private Boolean autoRead;
    private Boolean autoClose;
    private Boolean soBroadcast;
    private Integer soSndbuf;
    private Integer soRcvbuf;
    private Boolean soReuseaddr;
    private Integer soLinger;
    private Integer soBacklog;
    private Integer soTimeout;
    private Integer ipTos;
    private String ipMulticastAddr;
    private String ipMulticastIf;
    private Integer ipMulticastYtl;
    private Boolean ipMulticastLoopDisabled;
    private Boolean singleEventexecutorPerGroup;


    @Override
    protected void buildOption() {
        this.putOption(ChannelOption.SO_KEEPALIVE, true);
        this.putOption(ChannelOption.TCP_NODELAY, getTcpNodelay());
        this.putOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, getConnectionTimeoutMills());
        this.putOptionBean(ChannelOption.ALLOCATOR, getAllocator());
        this.putOptionBean(ChannelOption.RCVBUF_ALLOCATOR, getRecvAllocator());
        this.putOptionBean(ChannelOption.MESSAGE_SIZE_ESTIMATOR, getMessageSizeEstimator());
        this.putOption(ChannelOption.WRITE_SPIN_COUNT, getWriteSpinCount());
        this.putOptionBean(ChannelOption.WRITE_BUFFER_WATER_MARK, getWriteBufferWaterMark());
        this.putOption(ChannelOption.ALLOW_HALF_CLOSURE, getAllowHalfClosure());
        this.putOption(ChannelOption.AUTO_READ, getAutoRead());
        this.putOption(ChannelOption.AUTO_CLOSE, getAutoClose());
        this.putOption(ChannelOption.SO_BROADCAST, getSoBroadcast());
        this.putOption(ChannelOption.SO_SNDBUF, getSoSndbuf());
        this.putOption(ChannelOption.SO_RCVBUF, getSoRcvbuf());
        this.putOption(ChannelOption.SO_REUSEADDR, getSoReuseaddr());
        this.putOption(ChannelOption.SO_LINGER, getSoLinger());
        this.putOption(ChannelOption.SO_BACKLOG, getSoBacklog());
        this.putOption(ChannelOption.SO_TIMEOUT, getSoTimeout());
        this.putOption(ChannelOption.IP_TOS, getIpTos());
        this.putOptionBean(ChannelOption.IP_MULTICAST_ADDR, getIpMulticastAddr());
        this.putOptionBean(ChannelOption.IP_MULTICAST_IF, getIpMulticastIf());
        this.putOption(ChannelOption.IP_MULTICAST_TTL, getIpMulticastYtl());
        this.putOption(ChannelOption.IP_MULTICAST_LOOP_DISABLED, getIpMulticastLoopDisabled());
        this.putOption(ChannelOption.SINGLE_EVENTEXECUTOR_PER_GROUP, getSingleEventexecutorPerGroup());
    }


}
